package cn.ixiaoxin.deepchat.controller;

import cn.ixiaoxin.deepchat.entity.Friend;
import cn.ixiaoxin.deepchat.service.FriendService;
import cn.ixiaoxin.deepchat.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/friend")
public class FriendController {

    @Autowired
    private FriendService friendService;

    // 添加好友
    @PostMapping("/add")
    public Result<?> addFriend(@RequestParam Long userId,
                               @RequestParam Long friendId,
                               @RequestParam(required = false) String remark) {
        return friendService.addFriend(userId, friendId, remark);
    }

    // 删除好友
    @PostMapping("/delete")
    public Result<?> deleteFriend(@RequestParam Long userId, @RequestParam Long friendId) {
        return friendService.deleteFriend(userId, friendId);
    }

    // 获取好友列表
    @PostMapping("/list")
    public Result<?> getFriends(@RequestBody Friend friend) {
        return friendService.getFriends(friend);
    }
}
